<?php
/**
 * Description: 获取教师信息
 * User: devforma
 * Date: 16/1/6
 * Time: 17:59
 */

require LIB_DIR . '/LiveCourse.class.php';

class GetLectorInfo implements iController {

    /**
     * api请求处理主函数
     * @param array $queryArgs 就是$_REQUEST变量
     * @return array api返回结果，必须含response_code
     */
    public function output($queryArgs) {
        global $cmsdb;

        if (empty($queryArgs['lector_id']) || !filter_var($queryArgs['lector_id'], FILTER_VALIDATE_INT)) {
            return genOutput(1000);
        }

        $lector = $cmsdb->getRow('SELECT * FROM `data_teacher` WHERE `id`=:tid', array(':tid' => $queryArgs['lector_id']));
        if (empty($lector)) {
            return genOutput(1001);
        }

        return genOutput(1, array(
            'id' => intval($lector->id),
            'grade_score' => round($lector->grade_score, 1),
            'introduction' => $lector->introduction,
            'avatar' => $lector->avatar,
            'name' => $lector->name
        ));
    }
}